﻿using UnityEngine;
using System.Collections;
using Com.ZX;
using System;

public abstract class BaseUnitPoolable<T> : BaseUnit, IPoolable<T> where T: IPoolable<T>
{
    private bool isRecyclable = false;
    public BaseUnitPoolable()
	{ }
    
    void Awake()
    {

    }

    protected override void onEnable()
    {
        isRecyclable = true;
    }

    void Start()
    {
        //isRecyclable = true;
    }


    public override int Id
	{
		get
		{
			return base.Id;
		}

		set
		{
			base.Id = value;
		}
	}

    public IObjectPool<T> pool
    {
        get;set;
    }

    public virtual void onRecycle()
	{
        //CustomDebug.Log("onRescycle:"+this.Id+this.name);
        //CustomDebug.Log("sd");
        pool.RecyleObj(Id);
        isRecyclable = false;
        //pool.onRecycle(）;
        //throw new NotImplementedException();
    }

    void OnDisable()
    {
        if (isRecyclable)
            onRecycle();
    }
}

